-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear completion when switching windows via click #8118
Clear completion when switching windows via click #8118
Conversation
The completion component assumes that it operates on the same View but it's possible to break this assumption by switching windows through left-clicking. I believe we should clear the completion menu when switching windows to fix this. This change fixes a panic for this scenario: * Open a buffer with LSP completion available * Split the window (for example '<C-w>v') * Enter insert mode and trigger the completion menu * Select a completion candidate (for example with '<C-n>') * Switch to the original window by left-clicking in its area * Enter insert mode and make edits (for example 'o<backspace>') This will trip the 'assert_eq' in Document::restore.
Ideally we would close completion on any window switch from within |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can merge this as is to get the panic out of tree but I actually included the same fix in #8021 :D
Sorry I confused something. This is a good catch! Not quite as good as doing it in editor::focus but realistically changing focus while a prompt is otherwise impossible anyway.
That issue was about the search prompt not completion. Could we do the same there (close the current prompt)? |
Yeah, I just mean that for both prompts and completion that we need access to the compositor from within (helix-view's) Editor to solve it really nicely as you say in #5632. It should be possible to also close other components here: let callback = if view_id != prev_view_id {
self.clear_completion(editor);
let callback: crate::compositor::Callback = Box::new(|compositor, _| {
// Close any prompts or other components.
});
Some(callback)
} else {
None
};
editor.focus(view_id);
editor.ensure_cursor_in_view(view_id);
return EventResult::Consumed(callback); But that may need larger changes to the prompt and maybe other components. We would want to cancel whatever the prompt had selected, for example if you had I think it's possible with some more changes to the components that could be closed but it isn't quite trivial so I'd like to leave it off of this PR if possible. |
The completion component assumes that it operates on the same View but it's possible to break this assumption by switching windows through left-clicking. I believe we should clear the completion menu when switching windows to fix this. This change fixes a panic for this scenario: * Open a buffer with LSP completion available * Split the window (for example '<C-w>v') * Enter insert mode and trigger the completion menu * Select a completion candidate (for example with '<C-n>') * Switch to the original window by left-clicking in its area * Enter insert mode and make edits (for example 'o<backspace>') This will trip the 'assert_eq' in Document::restore.
The completion component assumes that it operates on the same View but it's possible to break this assumption by switching windows through left-clicking. I believe we should clear the completion menu when switching windows to fix this. This change fixes a panic for this scenario: * Open a buffer with LSP completion available * Split the window (for example '<C-w>v') * Enter insert mode and trigger the completion menu * Select a completion candidate (for example with '<C-n>') * Switch to the original window by left-clicking in its area * Enter insert mode and make edits (for example 'o<backspace>') This will trip the 'assert_eq' in Document::restore.
The completion component assumes that it operates on the same View but it's possible to break this assumption by switching windows through left-clicking. I believe we should clear the completion menu when switching windows to fix this. This change fixes a panic for this scenario: * Open a buffer with LSP completion available * Split the window (for example '<C-w>v') * Enter insert mode and trigger the completion menu * Select a completion candidate (for example with '<C-n>') * Switch to the original window by left-clicking in its area * Enter insert mode and make edits (for example 'o<backspace>') This will trip the 'assert_eq' in Document::restore.
The completion component assumes that it operates on the same View but it's possible to break this assumption by switching windows through left-clicking. I believe we should clear the completion menu when switching windows to fix this.
This change fixes a panic for this scenario:
<C-w>v
)<C-n>
)o<backspace>
)This will trip the
assert_eq
in Document::restore.